package com.jlastu.dlxy_androidapp.view.details;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import com.jlastu.dlxy_androidapp.R;

public class ShopUser extends AppCompatActivity {
    Button reportButton ;
    ImageView back_button;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop_user);
        reportButton =  findViewById(R.id.reportButton);
        reportButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showReportDialog();
            }
        });
        //返回按钮
        back_button= findViewById(R.id.back_button);
        back_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ShopUser.this, StoreActivity.class);
                startActivity(intent);
                finish();
            }
        });
    }
    private void showReportDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(ShopUser.this);
        builder.setTitle("举报理由");
        builder.setMessage("请填写举报理由");

        // 设置输入框
        final EditText input = new EditText(ShopUser.this);
        builder.setView(input);

        // 设置确定按钮
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                String reason = input.getText().toString();
                if (!reason.isEmpty()) {
                    Toast.makeText(ShopUser.this, "举报成功", Toast.LENGTH_SHORT).show();
                    // 在这里处理举报逻辑
                }
            }
        });

        // 设置取消按钮
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                // 用户点击取消按钮，这里不做任何操作
            }
        });

        builder.show();
    }
}